<template>
	<view>
		<!-- 顶部导航栏 -->
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 common-title">{{ lang_personal.evaluateManager }}</view>
				<view></view>
			</view>
		</view>

		<!-- 分割线 -->
		<u-gap height="5" bgColor="#F9F9F9"></u-gap>

		<view>
			<mescroll-body height="calc(100vh - 118rpx - var(--status-bar-height))" ref="mescrollRef"
				@init="mescrollInit" @down="downCallback" @up="upCallback">
				<view>
					<view v-for="(item, index) in dataList" :key="index">
						<view style="padding: 0 40rpx 22rpx">
							<evaluate-item :item="item">
								<view slot="footer" class="flex">
									<view>{{ item.bodyTitle || '' }}</view>
								</view>
							</evaluate-item>
						</view>

						<!-- 分割线 -->
						<u-gap height="5" bgColor="#F9F9F9"></u-gap>
					</view>
					
					<!-- 留空 -->
					<view style="height: 200rpx;"></view>
				</view>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import { merchantCommentPage } from '@/api/merchant/merchant.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				dataList: []
			}
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				merchantCommentPage({
					pageNumber: page.num,
					pageSize: page.size
				}).then(res => {
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
